class Solution {
    public String minWindow(String ss, String tt) {
      char []s=ss.toCharArray();
      char []t=tt.toCharArray();
      int []hash1=new int[128];
      int []hash2=new int[128];
      int kinds=0,begin=-1,minlen=Integer.MAX_VALUE;
      for(char ch:t) if(hash1[ch]++==0) kinds++;

      for(int left=0,right=0,count=0;right<ss.length();right++){
        if(++hash2[s[right]]==hash1[s[right]]) count++;

        while(count==kinds){
            if(right-left+1<minlen){
                begin=left;
                minlen=right-left+1;
            }
            if(hash2[s[left]]--==hash1[s[left++]])count--;
            //hash2[s[left++]]--;
            //char out=s[left++];
            //if(hash2[out]--==hash1[out]) count--;
        }

      } 
      if(begin==-1)
        return new String();
      else
        return ss.substring(begin,begin+minlen);
      
    }
}